Fix up filter wreckage I introduced with new arg parsing. From Mottram.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 12 Feb 2003 03:45:22 +0000 (03:45 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 12 Feb 2003 03:45:22 +0000 (03:45 +0000)
gpsbabel/duplicate.c
gpsbabel/filter_vecs.c
gpsbabel/position.c

index 6dbf569fe4c41aa34d0cdf9916728df083288ff7..1f29ee2d670399a7ba7c09cf29701b42bc53a07f 100644 (file)
@@ -23,8 +23,6 @@
 
 extern queue waypt_head;
 
-static int duplicate_shortname = 0;
-static int duplicate_location = 0;
 static char *snopt = NULL;
 static char *lcopt = NULL;
 
@@ -149,7 +147,7 @@ duplicate_process(void)
 {
        queue * elem, * tmp;
        waypoint * waypointp;
-       btree_node * newnode, * btmp, * ftmp, * sup_tree = NULL;
+       btree_node * newnode, * btmp, * sup_tree = NULL;
        unsigned long crc = 0;
        struct { char shortname[32]; char lat[13]; char lon[13]; } dupe;
         waypoint * delwpt = NULL;
@@ -159,11 +157,11 @@ duplicate_process(void)
 
                memset(&dupe, '\0', sizeof(dupe));
 
-               if (duplicate_shortname) {
+               if (snopt) {
                        strncpy(dupe.shortname, waypointp->shortname, sizeof(dupe.shortname) - 1);
                }
 
-               if (duplicate_location) {
+               if (lcopt) {
                        /* let sprintf take care of rounding */
                        sprintf(dupe.lat, "%11.6f", waypointp->position.latitude.degrees);
                        sprintf(dupe.lon, "%11.6f", waypointp->position.longitude.degrees);
@@ -198,8 +196,6 @@ duplicate_process(void)
 void
 duplicate_init(const char *args) 
 {
-       duplicate_shortname = snopt != NULL;
-       duplicate_location = lcopt != NULL;
 }
 
 void
index 47e22ba72b8168df3f0d8dbcfe1d01673a940fff..4dc76b0de0c3a97fc20b8c90781c1f623f20af0f 100644 (file)
@@ -103,9 +103,15 @@ void
 disp_filter_vecs(void)
 {
        fl_vecs_t *vec;
+       arglist_t *ap;
+
        for (vec = filter_vec_list; vec->vec; vec++) {
                printf("        %-20.20s  %-50.50s\n",
                        vec->name, vec->desc);
+               for (ap = vec->vec->args; ap && ap->argstring; ap++) {
+                       printf("          %-18.18s    %-.50s\n",
+                               ap->argstring, ap->helpstring);
+               }
        }
 }
 
index 3a53fe98b9af7d0050f6e7e666f78a225cd324a4..5e69f5e0b80df36c3cf632933544f34df4e20a78 100644 (file)
 extern queue waypt_head;
 
 static double pos_dist;
+static char *distopt;
+
+static
+arglist_t position_args[] = {
+       {"distance", &distopt, "Maximum positional distance (required)"},
+       {0, 0, 0}
+};
 
 static double
 gc_distance(double lat1, double lon1, double lat2, double lon2)
@@ -117,18 +124,16 @@ position_process(void)
 void
 position_init(const char *args) {
        char *fm;
-       char *p;
 
-       p = get_option(args, "distance");
+       pos_dist = 0;
 
-       if (p) {
-               pos_dist = strtod(p, &fm);
+       if (distopt) {
+               pos_dist = strtod(distopt, &fm);
 
                if ((*fm == 'm') || (*fm == 'M')) {
                         /* distance is meters */
                        pos_dist *= 3.2802;
                }
-               xfree(p);
        }
 }
 
@@ -140,5 +145,5 @@ filter_vecs_t position_vecs = {
        position_init,
        position_process,
        position_deinit,
-       NULL
+       position_args
 };